package com.example.jiaju.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.example.jiaju.R;
import com.example.jiaju.databinding.FurnitureInspirationItemBinding;
import com.example.jiaju.entity.BBS;
import com.example.jiaju.entity.FurnitureInspiration;

import java.util.List;

public class FurnitureInspirationAdapter extends RecyclerView.Adapter<FurnitureInspirationAdapter.MyViewHolder> {
    private List<BBS.PageDTO> list;
    public FurnitureInspirationAdapter(List<BBS.PageDTO> list) {
        this.list = list;
    }
    @NonNull
    @Override
    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        FurnitureInspirationItemBinding binding= DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()),
                R.layout.furniture_inspiration_item,parent,false);
        MyViewHolder myViewHolder=new MyViewHolder(binding.getRoot());
        myViewHolder.binding=binding;
        return myViewHolder;
    }
    @Override
    public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
        holder.binding.setItem(list.get(position));
    }
    @Override
    public int getItemCount() {
        return list.size();
    }
    static class MyViewHolder extends RecyclerView.ViewHolder {
        FurnitureInspirationItemBinding binding;
        public MyViewHolder(@NonNull View itemView) {
            super(itemView);
        }
    }
}
